package pl.com.sthaether.mc.main;

import javafx.scene.control.SplitPane;
import javafx.scene.layout.BorderPane;
import pl.com.sthaether.mc.main.menu.MCMenuBar;
import pl.com.sthaether.mc.main.toolbar.MCToolbar;
import pl.com.sthaether.mc.main.workspace.MCWorkspacePane;

public class MCMainPane extends BorderPane {

    private MCMenuBar menuBar;

    private MCToolbar toolbar;

    private MCWorkspacePane workspacePane;

    private SplitPane mainSplit;


    public MCMainPane() {
        init();
    }

    public static MCMainPane getInstance() {
        return MCMainPaneHolder.INSTANCE;
    }

    private void init() {
        mainSplit = new SplitPane();
        menuBar = MCMenuBar.getInstance();
        toolbar = MCToolbar.getInstance();
        workspacePane = MCWorkspacePane.getInstance();
        menuBar.prefWidthProperty().bind(prefWidthProperty());
        toolbar.prefHeightProperty().bind(heightProperty());
        workspacePane.prefHeightProperty().bind(heightProperty());
        mainSplit.setDividerPosition(0, 0.25);
        mainSplit.getItems().addAll(toolbar, workspacePane);
        this.setTop(menuBar);
        this.setCenter(mainSplit);
    }

    public MCMenuBar getMenuBar() {
        return menuBar;
    }

    public MCToolbar getToolbar() {
        return toolbar;
    }

    public MCWorkspacePane getWorkspacePane() {
        return workspacePane;
    }

    private static final class MCMainPaneHolder {
        protected static final MCMainPane INSTANCE = new MCMainPane();
    }
}
